import {Button ,Drawer,Table} from "antd";
import React, { useState } from 'react';
import axios from '../../components/service/request'

const Index = ({ record, edit }) => {


    const [isModalOpen, setIsModalOpen] = useState(false);
    const [dataSource, setdataSource] = useState(false);
    const [open, setOpen] = useState(false);

    const showDrawer = () => {
        setOpen(true);
        haok()
    };
  
    const onClose = () => {
      setOpen(false);
    };

    const showModal = () => {
      setIsModalOpen(true);
    };
  
    const handleCancel = () => {
      setIsModalOpen(false);
    };
 
    const haok = () => { 
        showModal()
        //获取预约用户信息接口
        axios.post('http://localhost:8080/admin/boomanage/bootecord/getResList', record)
            .then(res => {
                if (res.code === 200) {
                    console.log(res);
                    setdataSource(res.data);
                } else {
                    console.log("获取失败"); 
                
                }
            });
    }
      
    const columns = [
        {
            title: '姓名',
            dataIndex: 'name',
            key: 'name',
            width:'150px'
        },
        {
            title: '学号',
            dataIndex: 'number',
            key: 'number',
            width:'320px'
        },
        {
            title: '联系方式',
            dataIndex: 'phone',
            key: 'phone',
        },
    ]
    const modelstyle ={
       width :"800px",
       height :"1300px"
    }
   
      
      
    return <>
        <Button type="primary" className={'button-default'} size={'small'}
                onClick={() => edit(record)}>
              申请批准
        </Button>

        <Button type="primary"
         className={'button-default'} size={'small'}
         onClick={showDrawer}
        >
            查看详情
        </Button>
        <Drawer
        onClose={onClose}
        open={open}
        width={modelstyle.width}
        style={{ height: modelstyle.height + ' !important' }} // 设置Modal的高度
        >
            <Table dataSource={dataSource} columns={columns} />;
        </Drawer>

    </>
}
//申请批准与查看详情组件

export default Index;